#include "Affichage.h"

#include <iostream>
#include <iomanip>
#include <vector>

#include <boost/foreach.hpp>
#include <boost/assign/list_of.hpp>

using namespace std;
using namespace boost;
using namespace boost::assign;

void centrer( const string& element, unsigned& avant, unsigned& apres )
{
  unsigned longueur( element.size() );

  string::const_iterator strIt, strFin( element.end() );

  for ( strIt = element.begin(); strIt != strFin; strIt++ )
    {
      if ( unsigned( *strIt ) > 255 )
	{
	  longueur--;
	  strIt++;
	}
    }

  avant = ( 80u - longueur ) / 2u ;
  apres = 80u - avant - longueur;
}

void produireHeader( const string& nomPrgm,
		     const string& description )
{
  unsigned avant, apres;
  vector< string > lignes = list_of( "- " + nomPrgm + " -" )
    ( description )( " " )( "Développé par Johan \"Solo\" Luisier" )
    ( "Projet ADD" )( "2007" );

  cout << setfill('#') << setw(82) << '#' << endl << setfill(' ');
  BOOST_FOREACH( string ligne, lignes )
    {
      centrer( ligne, avant, apres );
      cout << '#' << setw( avant ) << ' ' << ligne
	   << setw( apres ) << ' ' << '#' << endl;
    }
  cout << setfill('#') << setw(82) << '#' << endl << setfill(' ');

}
